import device from '@system.device';
import prompt from '@system.prompt';
export default {
    data: {
        options:[
            {value:'on',icon:'common/icons/on.png'},
            {value:'off',icon:'common/icons/off.png'},
            {value:'auto',icon:'common/icons/auto.png'},
        ],
        optionIndex:0,
        windowHeight:0,
        position:'back'

    },
    onInit(){
        device.getInfo({
            success:(data)=> {
                this.windowHeight=data.windowHeight
            },
        });
    },
    change(){
        this.$element("apiMenu").show({x:0,y:this.windowHeight-220});
    },
    onMenuSelected(e) {
        prompt.showToast({
            message: "切换灯光"
        })
        this.optionIndex=e.value;
    },
    changePosition(){
        this.position=this.position==='back'?'front':'back';
        prompt.showToast({
            message: "切换摄像头"
        })
    },
    photo(){
        prompt.showToast({
            message: "拍照"
        })
        console.log('photo')
        this.$element('camera').takePhoto({quality:'normal',
            success:()=>{
            console.log('success');
        },
        fail:(err)=>{
            console.log(err)
        },
            complete:()=>{
                console.log('complete')
            }
        })
    }
}
